package gemini.castor.ui.client.page.content.store.catalog;

import com.google.gwt.event.shared.GwtEvent;

public class CatalogEvent extends GwtEvent<CatalogHandler> {

	private static Type<CatalogHandler> TYPE;
	
	public static Type<CatalogHandler> getType() {
		if (TYPE == null)
			TYPE = new Type<CatalogHandler>();
		return TYPE;
	}
	
	public enum ForwardType {
		VIEW_PRODUCTS;
	}
	
	public CatalogEvent(ForwardType forwardType) {
		super();
		this.setForwardType(forwardType);
	}
	
	private ForwardType forwardType;

	@Override
	protected void dispatch(CatalogHandler handler) {
		if(forwardType.equals(ForwardType.VIEW_PRODUCTS)){
			handler.onViewProducts(this);
		}
	}
	
	@Override
	public Type<CatalogHandler> getAssociatedType() {
		return getType();
	}

	public void setForwardType(ForwardType forwardType) {
		this.forwardType = forwardType;
	}

	public ForwardType getForwardType() {
		return forwardType;
	}
}
